package com.genius.mobile_page.jiekou.yundai.service.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.genius.adminmanager.other.entity.FillAddJson;
import com.genius.adminmanager.other.entity.ResponseJson;
import com.genius.adminmanager.other.entity.SessionJson;
import com.genius.adminmanager.user.entity.UserJson;
import com.genius.dingding.util.GeniusConfig;
import com.genius.mobile_page.common.ErrorResponseData;
import com.genius.mobile_page.common.ResponseData;
import com.genius.mobile_page.common.SuccessResponseData;
import com.genius.mobile_page.jiekou.yundai.service.YundaiService;
import com.genius.mobile_page.pandian.pandianUtil;
import com.genius.mobile_page.pandian.service.PandianEveryService;
import com.genius.mobile_page.pandian.service.PandianService;
import com.genius.mobile_page.pingjia.PingjiaUtil;
import com.genius.mobile_page.pingjia.service.PingjiaServiceAdapter;
import com.genius.mobile_page.siji.service.SijiqiandaoService;
import com.genius.unite_platform.meeting_info.entity.Meeting_infoEntity;
import com.genius.unite_platform.meeting_info_detail.entity.Meeting_info_detailEntity;
import com.genius.unite_platform.notice_info.entity.Notice_infoEntity;
import com.genius.unite_platform.work_plan_info.entity.Work_plan_infoEntity;
import com.genius.workflow.element.SQLBean;
import com.genius.workflow.page.PageResult;
import com.genius.workflow.page.SearchResult;
import com.genius.workflow.page.SqlLang;
import com.genius.workflow.util.ConnectionException;
import com.genius.workflow.util.DBClosedException;
import com.genius.workflow.util.DBTools;
import com.genius.workflow.util.DBTools2;
import com.genius.workflow.util.DBUtils;
import com.genius.workflow.util.GetNo;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSON;

@Service("yundaiService")
public class YundaiServiceImpl implements YundaiService{

	@Override
	public JSONObject getYundaiInfo(JSONObject parms) {
		JSONObject resJson = new JSONObject();
		try {
			if(ObjectUtil.isEmpty(parms.getString("tyshxydm"))){
				resJson.put("ret", "3");
				resJson.put("msg", "入参格式错误，参数必须包含统一社会信用代码");
			}else{
				StringBuilder sql = new StringBuilder("select s1.tyshxydm,s1.qymc,s1.clrq,s1.mdyt,s2.jehjone,s2.jehjtwo"
						+ ",s2.zhdhrq,concat(s2.njebhbl,'%')njebhbl,concat(s2.yjebhbl,'%') yjebhbl,s2.sfdh from "
						+ "(select tyshxydm,shopcode,qymc,clrq,mdyt from "+GeniusConfig.ZHIBIAODATABASE+".yundai_info"
								+ " where tyshxydm = ?)s1"
						+ " left join "
						+ GeniusConfig.ZHIBIAODATABASE+".yundai_info_data s2 on s1.shopcode = s2.shopcode");
				
				JSONObject result = DBUtils.select(sql.toString(),new String[]{parms.getString("tyshxydm")});
				if(result != null && ObjectUtil.isNotEmpty(result.getString("tyshxydm"))){
					if(ObjectUtil.equals("1", result.getString("mdyt"))){
						resJson.put("ret", "0");
						resJson.put("msg", "返回成功");
						resJson.put("data", result);
					}else{
						resJson.put("ret", "5");
						resJson.put("msg", "门店业态非金虎超市");
						
					}
					
				}else{
					resJson.put("ret", "1");
					resJson.put("msg", "查询为空");
				}
				
			}
			
			
		} catch (SQLException throwables) {
			
			throwables.printStackTrace();
			resJson.put("ret", "99");
			resJson.put("msg", "操作失败");
		} catch (Exception e) {
			e.printStackTrace();
			resJson.put("ret", "99");
			resJson.put("msg", "操作失败");
		}
		return resJson;
	}
	
}

